<?php

class comment extends Model
{

	function getComment($id)
	{
		$gomment = $this->db->getAll("SELECT article.post,
				comment.stud_no, 
				comment.date,
				comment.comment,
				organization.name Org
			FROM article,organization, comment 
			WHERE article.org_id = organization.org_id 
			AND article.org_id = 1
			ORDER BY comment.date DESC;",
			array( (int) $id )	
		);
		return $gphoto;
	}

	function insertComment ( $article_id, $stud_no, $date, $comment )
	{
		$icomment = $this->db->execute("INSERT INTO comment( article_id,
			stud_no,
			date,
			comment )
			VALUES ( ?, ?, ?, ? )", 
			array( (int) $article_id, $stud_no, $date, $comment )
		);
		return $iomment;
	}

	function updateComment( $article_id, $stud_no, $date, $comment, $comment_id ) 
	{
		$ucomment = $this->db->execute("UPDATE comment
			SET article_id = ?,
			stud_no = ?,
			date = ?,
			comment = ?			
			WHERE comment_id = ?",
			array( (int) $article_id, $stud_no, $date, $comment, $comment_id  )
		);
		return $ucomment;
	}

	function deleteComment ( $comment_id )
	{
		$dphoto = $this->db->execute("DELETE FROM comment
			WHERE comment_id  = ? ",
			array( (int) $comment_id  )
		);
	}
}